﻿using RXY_Mall.Core;
using RXY_Mall.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RXY_Mall.Services
{
    public class CouponService
    {
        /// <summary>
        /// 判断商品是否有优惠
        /// </summary>
        /// <param name="coupon">优惠券</param>
        /// <param name="goods_id">商品ID</param>
        /// <param name="category_id">商品分类ID</param>
        /// <param name="shop_id">商品所在店铺ID</param>
        /// <returns></returns>
        public bool IsCouponByGoods(gw_marketing_coupon coupon, int goods_id, int category_id, int shop_id)
        {
            ////判断是否满足优惠活动
            //if (string.IsNullOrEmpty(coupon.allow_goods) && string.IsNullOrEmpty(coupon.allow_categories)
            //    && string.IsNullOrEmpty(coupon.allow_shops))
            //{
            //    return true;
            //}

            ////商品
            //var goods_id_list = CommonHelper.StringConvertListOfInt(coupon.allow_goods);
            //if (goods_id_list != null)
            //{
            //    if (goods_id_list.Contains(goods_id))
            //    {
            //        return true;
            //    }
            //    return false;
            //}
            ////分类
            //var category_id_list = CommonHelper.StringConvertListOfInt(coupon.allow_categories);
            //if (category_id_list != null)
            //{
            //    if (category_id_list.Contains(category_id))
            //    {
            //        return true;
            //    }
            //    return false;
            //}
            ////商店
            //var shop_id_list = CommonHelper.StringConvertListOfInt(coupon.allow_shops);
            //if (shop_id_list != null)
            //{
            //    if (shop_id_list.Contains(shop_id))
            //    {
            //        return true;
            //    }
            //    return false;
            //}

            return true;
        }
    }
}
